package com.easylinkin.linkappapi.meterbilling.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;

import com.easylinkin.linkappapi.common.utils.DateUtil;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@TableName(value = "cbjf_meter_device_config")
public class MeterDeviceConfig {
    /**
     * 主键ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 设备编码
     */
    @TableField(value = "device_code")
    private String deviceCode;

    /**
     * 设备类型 0：水表:1：电表
     */
    @TableField(value = "meter_type")
    private Integer meterType;

    /**
     * 房间ID
     */
    @TableField(value = "room_id")
    private Integer roomId;

    /**
     * 抄表时间
     */
    @TableField(value = "record_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime recordTime;

    /**
     * 日用阀值
     */
    @TableField(value = "day_threshold")
    private BigDecimal dayThreshold;

    /**
     * 月用阀值
     */
    @TableField(value = "month_threshold")
    private BigDecimal monthThreshold;

    /**
     * 创建时间
     */
    @TableField(value = "create_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime createTime;

    /**
     * 修改时间
     */
    @TableField(value = "modify_time")
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
    private LocalDateTime modifyTime;

    /**
     * 删除状态（0：正常，1：删除）
     */
    @TableField(value = "delete_status")
    private Integer deleteStatus;

    /**
     * 租户ID
     */
    @TableField(value = "tenant_id")
    private String tenantId;



    /**
     * 房间名称
     */
    @TableField(exist = false)
    private String roomName;

    /***
     * 设备类型名称
     */
    @TableField(exist = false)
    private String meterTypeName;

    /**
     * 房间编码
     */
    @TableField(exist = false)
    private String roomCode;

    /***
     * 批量id
     */
    @TableField(exist = false)
    private List<Integer> ids;

    /***
     * 房间批量查询
     */
    @TableField(exist = false)
    private List<Integer> roomIds;

    @TableField(exist = false)
    private String deviceName;

    @TableField(exist = false)
    private String phone;

    /**
     * 是否当做新绑定设备，从绑定时间开始计算能耗扣费
     */
    @TableField(exist = false)
    private boolean isNewBind;

    @TableField(exist = false)
    private Date compareDate;
    
    public void setCompareDate(Date compareDate){
        this.compareDate = compareDate;
        Date dateCreateTime = DateUtil.localDateTimeToDate(this.createTime);
        if(compareDate.compareTo(dateCreateTime) < 0){
            this.isNewBind = true;
        }
    }
}